function onLoad() {

  if(document.getElementById('exp') != null) document.getElementById('head:searchBtn').click();

  showNavigation();
}

function val(event, type) {

  return psd(event, type, null)
}

function psd(event, type, focusId) {     alert('nuevo');

  var numbers = "0123456789";

  var characters = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

  var numbers_characters = numbers + characters;

  var keys_specials = [8, 9, 37, 39, 46]; //8 = BackSpace, 9 = Tab, 46 = Del key, 37 = left key, 39 = right key

  var keys_numbers  = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 110]; // 110 = decimal point


  type= type=='num'? numbers : type=='car'? characters : type=='num_car'? numbers_characters : type;


  var evento = event || window.event;

  var key = evento.charCode || evento.keyCode;


  if(key == 13 && focusId != null) { document.getElementById('head:'+focusId).focus(); }


  for (var i=0; i<keys_numbers.length; i++)

  if(key == keys_numbers[i]) return true;


  for (var j=0; j<keys_specials.length; j++)

  if(key == keys_specials[j]) return true;


  var character = String.fromCharCode(key);

  return type.indexOf(character) != -1;
}

function nxt(event, focusId) {

  var evento = event || window.event;

  var key = evento.charCode || evento.keyCode;

  if(key == 13 && focusId != null) { document.getElementById(focusId).focus(); return false }
}

function tab() {

  if(event.keyCode == 13) //13 is enter key

     event.keyCode=9; //return 9 the tab key
}

function showNavigation() {

    var show= document.getElementById('navigation').style.display;

    document.getElementById('navigation').style.display= show=='none'? 'block' :'none';
}

function showTimeServer() {

    getTimeServer();

    document.getElementById("head:dateClient").innerHTML = 'C ' + toStringTime(new Date());

    setTimeout('showTimeServer()',1000);
}

function getTimeServer(){

    var url = document.getElementById('contextPath').innerHTML.split('business')[0]+'TimeServlet';

    request= window.ActiveXObject? new ActiveXObject('Microsoft.XMLHTTP') : window.XMLHttpRequest? new XMLHttpRequest() : null;

    request.onreadystatechange = showTime;

    request.open('POST',url,true);

    request.send();
}

function showTime(){

    if(request.readyState == 4) {

    var fecha= request.responseText.split(' ');

    var date= fecha[0].split('-');

    var time= fecha[1].split(':');

    var digital= new Date(date[0],date[1]-1,date[2],time[0],time[1],time[2]);

    document.getElementById('head:dateServer').innerHTML = 'S ' + toStringTime(digital);

    }
}

function toStringTime(Digital) {

    var fullYear= Digital.getFullYear();

    var month= Digital.getMonth() + 1;

    var day= Digital.getDate();


    if (month<=9) month= '0' + month;

    if (day <= 9) day= '0' + day;


    var hours=Digital.getHours();

    var minutes=Digital.getMinutes();

    var seconds=Digital.getSeconds();

    var dn='am';


    if (hours > 12) { dn='pm'; hours=hours-12; }

    if (hours == 0) hours= 12;

    if (minutes<=9) minutes= '0' + minutes;

    if (seconds<=9) seconds= '0' + seconds;


    return hours + ':' + minutes + ':' + seconds + ' ' + dn +' ' + day + '/' + month + '/' + fullYear;
}

function getParamUrl(name) {

    name = name.replace(/[\[]/,'\\\[').replace(/[\]]/,'\\\]');

    var regex = new RegExp( '[\\?&]'+name+'=([^&#]*)' );

    var results = regex.exec( window.location.href );

    return results != null? results[1] : null;
}

function printerPOS(divId) {

    printer(divId,'300','500')
}

function printer(divId, width, height) {

    var doc= document.getElementById(divId);

    var w= window.open(' ','popup','width='+width+',height='+height);

    w.document.write( doc.innerHTML );

    w.document.close();

    w.print();

    w.close();

    //<DIV ID="seleccion">Este texto es lo que se imprime</DIV>

    //<a href="javascript:printerPOS('seleccion')">Imprimir</a>
}


